package top.lishuoboy.boot92.datetime.serializable.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.lishuoboy.boot92.datetime.serializable.domain.DateTime;
import top.lishuoboy.boot92.datetime.serializable.service.DateTimeService;

import java.util.List;

/**
 * 2025/5/15
 *
 * @author lishuoboy
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/DateTime")
public class DateTimeController {

    private final DateTimeService dateTimeService;

    @PostMapping("/saveBatch")
    List<DateTime> saveBatch(@RequestBody List<DateTime> dateTimeList) {
        log.warn("dateTimeList=={}", dateTimeList);
        dateTimeService.saveBatch(dateTimeList);
        log.warn("dateTimeList=={}", dateTimeList);
        return dateTimeList;
    }

    @PostMapping("/list")
    List<DateTime> list() {
        List<DateTime> dateTimeList = dateTimeService.list();
        log.warn("dateTimeList=={}", dateTimeList);
        return dateTimeList;
    }
}
